


var userid = {}
var usertimer = {}

module.exports.AddUser = AddUser;
function AddUser(_userid) 
{
    if(_userid in userid){
        return 1
    }
    userid[_userid] = 1
    return 0;
}


module.exports.DelUser = DelUser; 
function DelUser(_userid) 
{
    StopTimer(_userid, "pairlist");
    StopTimer(_userid, "coininfo");
    StopTimer(_userid, "bargraph");
    StopTimer(_userid, "transdepth");
    StopTimer(_userid, "mytransdepth");
    StopTimer(_userid, "lasttrade");

    if(!(_userid in userid)){
        delete userid[_userid]
    }

}

module.exports.AddTimer = AddTimer;
function AddTimer(_userid, _servertype, _timeid)
{
    if(_userid + "_" + _servertype in usertimer) {
        StopTimer(_userid, _servertype) 
    }
    console.log("timer id register " + _timeid)
    usertimer[_userid + "_" + _servertype] = _timeid
    return 0
} 

module.exports.GetTimer = GetTimer;
function GetTimer (_userid, _servertype) 
{
    if(_userid + "_" + _servertype in usertimer) {
        return usertimer[_userid + "_" + _servertype]
    }
    return 0;
}


module.exports.StopTimer = StopTimer;
function StopTimer(_userid, _servertype) 
{
    if((_userid + "_" + _servertype) in usertimer) {
        
        console.log("timer id unregister " + usertimer[_userid + "_" + _servertype])
        clearInterval(usertimer[_userid + "_" + _servertype])
    }
    
    return 0
}